package com.ruoyi.web.controller.member;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.XxTemporaryMemberConsumeRecord;
import com.ruoyi.system.service.IXxTemporaryMemberConsumeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 散客消费记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/member/temporaryMember/record")
public class XxTemporaryMemberConsumeRecordController extends BaseController
{
    @Autowired
    private IXxTemporaryMemberConsumeRecordService xxTemporaryMemberConsumeRecordService;

    /**
     * 查询散客消费记录列表
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(XxTemporaryMemberConsumeRecord xxTemporaryMemberConsumeRecord)
    {
        startPage();
        List<XxTemporaryMemberConsumeRecord> list = xxTemporaryMemberConsumeRecordService.selectXxTemporaryMemberConsumeRecordList(xxTemporaryMemberConsumeRecord);
        return getDataTable(list);
    }

    /**
     * 导出散客消费记录列表
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:export')")
    @Log(title = "散客消费记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XxTemporaryMemberConsumeRecord xxTemporaryMemberConsumeRecord)
    {
        List<XxTemporaryMemberConsumeRecord> list = xxTemporaryMemberConsumeRecordService.selectXxTemporaryMemberConsumeRecordList(xxTemporaryMemberConsumeRecord);
        ExcelUtil<XxTemporaryMemberConsumeRecord> util = new ExcelUtil<XxTemporaryMemberConsumeRecord>(XxTemporaryMemberConsumeRecord.class);
        util.exportExcel(response, list, "散客消费记录数据");
    }

    /**
     * 获取散客消费记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(xxTemporaryMemberConsumeRecordService.selectXxTemporaryMemberConsumeRecordByRecordId(recordId));
    }

    /**
     * 新增散客消费记录
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:add')")
    @Log(title = "散客消费记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XxTemporaryMemberConsumeRecord xxTemporaryMemberConsumeRecord)
    {
        xxTemporaryMemberConsumeRecord.setCreateBy(getUsername());
        return toAjax(xxTemporaryMemberConsumeRecordService.insertXxTemporaryMemberConsumeRecord(xxTemporaryMemberConsumeRecord));
    }

    /**
     * 修改散客消费记录
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:edit')")
    @Log(title = "散客消费记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XxTemporaryMemberConsumeRecord xxTemporaryMemberConsumeRecord)
    {
        xxTemporaryMemberConsumeRecord.setUpdateBy(getUsername());
        return toAjax(xxTemporaryMemberConsumeRecordService.updateXxTemporaryMemberConsumeRecord(xxTemporaryMemberConsumeRecord));
    }

    /**
     * 删除散客消费记录
     */
    @PreAuthorize("@ss.hasPermi('temporaryMember:record:remove')")
    @Log(title = "散客消费记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(xxTemporaryMemberConsumeRecordService.deleteXxTemporaryMemberConsumeRecordByRecordIds(recordIds));
    }
}
